package com.jd.basic.config;

import com.jd.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class LoginInterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 配置拦截器
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**")
                // 登录相关
                .excludePathPatterns("/login/**")
                // 注册相关，店铺入驻管理员注册，手机验证码和图片验证码，手机注册和邮箱注册
                // 上传图片和删除图片，fastdfs和minio，用户邮箱激活
                .excludePathPatterns("/shop/settlement/**","/verifyCode/**"
                        ,"/user/register/**","/fastDfs/**","/minio/**","/user/active/**")
                // 测试相关
                //放行swagger
                .excludePathPatterns("/swagger-resources/**", "/webjars/**",
                        "/v2/**", "/swagger-ui.html/**");
    }
}
